package com.kotlin.myapplication.mvp.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.EditText;

/**
 * 编辑框四周添加图片
 * 
 * @author 作者： zhazb
 *
 */
public class InputEditText extends EditText {

	public InputEditText(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public InputEditText(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public InputEditText(Context context) {
		super(context);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
	}

	// 在编辑框顶部添加图片
	public void setDrawableTop(Drawable top) {
		setCompoundDrawablesWithIntrinsicBounds(null, top, null, null);
	}

	// 在编辑框顶部添加图片
	public void setDrawableTop(int top) {
		setCompoundDrawablesWithIntrinsicBounds(0, top, 0, 0);
	}

	// 在编辑框顶部左边图片
	public void setDrawableRight(int right) {
		setCompoundDrawablesWithIntrinsicBounds(0, 0, right, 0);
	}

	// 在编辑框左边添加图片
	public void setDrawableLeft(int left) {
		setCompoundDrawablesWithIntrinsicBounds(left, 0, 0, 0);
	}

	// 在编辑框底部添加图片
	public void setDrawableButtom(int buttom) {
		setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, buttom);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}
}
